
contains(MOBILE_EXTENSIONS, vibra) {
  DEFINES += XQVIBRA_NO_LIBRARY
  LIBS -= -lxqvibra
  
  HEADERS += $${SOURCES_PREFIX}/vibra/xqvibra.h \
             $${SOURCES_PREFIX}/vibra/xqvibra_p.h \
             $${SOURCES_PREFIX}/vibra/vibra_global.h

  SOURCES += $${SOURCES_PREFIX}/vibra/xqvibra.cpp \
             $${SOURCES_PREFIX}/vibra/xqvibra_p.cpp

  LIBS += -lhwrmvibraclient    
}

contains(MOBILE_EXTENSIONS, telephony) {
  DEFINES += XQTELEPHONY_NO_LIBRARY  
  LIBS -= -lxqtelephony

  HEADERS += $${SOURCES_PREFIX}/telephony/xqtelephony.h \
             $${SOURCES_PREFIX}/telephony/xqtelephony_p.h \
             $${SOURCES_PREFIX}/telephony/ccalldialer.h \
             $${SOURCES_PREFIX}/telephony/ctelephonymonitor.h \
             $${SOURCES_PREFIX}/telephony/telephony_global.h
  
  SOURCES += $${SOURCES_PREFIX}/telephony/xqtelephony.cpp \
             $${SOURCES_PREFIX}/telephony/xqtelephony_p.cpp \
             $${SOURCES_PREFIX}/telephony/ccalldialer.cpp \
             $${SOURCES_PREFIX}/telephony/ctelephonymonitor.cpp
  
  LIBS += -letel3rdparty \
          -lcntmodel \
          -lbafl \
          -lefsrv \
          -lestor \
          -lexiflib.dll

CAPSNetworkServices += telephony
}

contains(MOBILE_EXTENSIONS, contacts) {
  DEFINES += XQCONTACTS_NO_LIBRARY
  LIBS -= -lxqcontacts

  HEADERS += $${SOURCES_PREFIX}/contacts/xqcontacts.h \
             $${SOURCES_PREFIX}/contacts/xqcontact.h \
             $${SOURCES_PREFIX}/contacts/xqcontact_p.h \
             $${SOURCES_PREFIX}/contacts/contacts_global.h \
             $${SOURCES_PREFIX}/contacts/xqcontacts_s60_p.h
  
  SOURCES += $${SOURCES_PREFIX}/contacts/xqcontacts.cpp \
             $${SOURCES_PREFIX}/contacts/xqcontact.cpp \
             $${SOURCES_PREFIX}/contacts/xqcontacts_s60_p.cpp
             
  INCLUDEPATH += /epoc32/include/app \
                 /epoc32/include/platform/app
  
  LIBS += -lcntmodel \
          -lbafl \
          -lefsrv \
          -lestor \
          -lexiflib.dll

  CAPSReadUserData += contacts
  CAPSWriteUserData += contacts
}

contains(MOBILE_EXTENSIONS, sensors) {
  DEFINES += XQSENSOR_NO_LIBRARY
  LIBS -= -lxqsensor
  
  HEADERS += $${SOURCES_PREFIX}/sensor/xqsensor.h \
             $${SOURCES_PREFIX}/sensor/xqaccsensor.h \
             $${SOURCES_PREFIX}/sensor/xqdeviceorientation.h \
             $${SOURCES_PREFIX}/sensor/xqdeviceorientation_p.h \
             $${SOURCES_PREFIX}/sensor/sensor_global.h
  
  SOURCES += $${SOURCES_PREFIX}/sensor/xqsensor.cpp \
             $${SOURCES_PREFIX}/sensor/xqaccsensor.cpp \
             $${SOURCES_PREFIX}/sensor/xqdeviceorientation.cpp \
             $${SOURCES_PREFIX}/sensor/xqdeviceorientation_p.cpp
  
  exists($${EPOCROOT}epoc32/release/winscw/udeb/SensrvClient.lib)| \
  exists($${EPOCROOT}epoc32/release/armv5/lib/SensrvClient.lib) {
    message("Building for Sensor Framework")
    DEPENDPATH += $${SOURCES_PREFIX}/sensor/framework
  
    HEADERS += $${SOURCES_PREFIX}/sensor/framework/xqsensor_p.h \
               $${SOURCES_PREFIX}/sensor/framework/xqaccsensor_p.h
    
    SOURCES += $${SOURCES_PREFIX}/sensor/framework/xqsensor_p.cpp \
               $${SOURCES_PREFIX}/sensor/framework/xqaccsensor_p.cpp
    
    LIBS += -lSensrvClient \
            -lsensrvutil
            
    CAPSReadReviceData += "sensors/framework"
  }
  else {
    exists($${EPOCROOT}epoc32/release/winscw/udeb/RRSensorApi.lib)| \
    exists($${EPOCROOT}epoc32/release/armv5/lib/RRSensorApi.lib) {
      message( "Building for Sensor plugin" )
    
      DEPENDPATH += $${SOURCES_PREFIX}/sensor/plugin
      
      HEADERS += $${SOURCES_PREFIX}/sensor/plugin/xqsensor_p.h \
                 $${SOURCES_PREFIX}/sensor/plugin/xqaccsensor_p.h
      
      SOURCES += $${SOURCES_PREFIX}/sensor/plugin/xqsensor_p.cpp \
                 $${SOURCES_PREFIX}/sensor/plugin/xqaccsensor_p.cpp
      
      LIBS += -lRRSensorApi
    }
    else {
      warning("Sensor API not found!")
    }
  }    
}

contains(MOBILE_EXTENSIONS, camera) {
  DEFINES += XQCAMERA_NO_LIBRARY
  LIBS -= -lxqcamera
  
  HEADERS += $${SOURCES_PREFIX}/camera/xqcamera.h \
             $${SOURCES_PREFIX}/camera/xqcamera_p.h \
             $${SOURCES_PREFIX}/camera/xqviewfinderwidget.h \
             $${SOURCES_PREFIX}/camera/xqviewfinderwidget_p.h \
             $${SOURCES_PREFIX}/camera/camera_global.h
  
  SOURCES += $${SOURCES_PREFIX}/camera/xqcamera.cpp \
             $${SOURCES_PREFIX}/camera/xqcamera_p.cpp \  
             $${SOURCES_PREFIX}/camera/xqviewfinderwidget.cpp \
             $${SOURCES_PREFIX}/camera/xqviewfinderwidget_p.cpp
             
  LIBS += -lfbscli

  !exists($${EPOCROOT}epoc32/release/armv5/urel/camerawrapper_s.lib) {
    message("Warning: camerawrapper_s.lib not found in your environment! See http://projects.forum.nokia.com/camerawrapper")
  }
    
  cameraDeps = \
    "debuglibrary          flogger.lib" \
    "$${LITERAL_HASH}if defined(WINS)" \
    "library               camerawrapper.lib" \
    "$${LITERAL_HASH}else" \
    "library               ecam.lib ecamadvsettings.lib" \
    "staticlibrary         camautofocus_s.lib camerawrapper_s.lib" \
    "$${LITERAL_HASH}endif"
    
  MMP_RULES += cameraDeps
  
  CAPSUserEnvironment += camera
}

contains(MOBILE_EXTENSIONS, calendar) {
  DEFINES += XQCALENDAR_NO_LIBRARY
  LIBS -= -lxqcalendar
  
  HEADERS += $${SOURCES_PREFIX}/calendar/xqcalendar.h \
             $${SOURCES_PREFIX}/calendar/xqcalendar_p.h \
             $${SOURCES_PREFIX}/calendar/xqcalendarentry.h \
             $${SOURCES_PREFIX}/calendar/xqcalendarentry_p.h \
             $${SOURCES_PREFIX}/calendar/calendar_global.h

  SOURCES += $${SOURCES_PREFIX}/calendar/xqcalendar.cpp \
             $${SOURCES_PREFIX}/calendar/xqcalendar_p.cpp \
             $${SOURCES_PREFIX}/calendar/xqcalendarentry.cpp
             
  INCLUDEPATH += /epoc32/include/app \
                 /epoc32/include/platform/app
  
  LIBS += -lcalinterimapi \
          -lestor \
          -lefsrv
          
  CAPSReadUserData += calendar
  CAPSWriteUserData += calendar
  CAPSReadDeviceData += calendar
  CAPSWriteDeviceData += calendar            
}

contains(MOBILE_EXTENSIONS, audio) {  
  DEFINES += XQAUDIO_NO_LIBRARY
  LIBS -= -lxqaudio

  HEADERS += $${SOURCES_PREFIX}/audio/xqaudio.h \
             $${SOURCES_PREFIX}/audio/xqaudio_p.h \
             $${SOURCES_PREFIX}/audio/audio_global.h

  SOURCES += $${SOURCES_PREFIX}/audio/xqaudio.cpp \
             $${SOURCES_PREFIX}/audio/xqaudio_p.cpp

  LIBS += -lmediaclientaudio \
          -lmediaclientaudioinputstream
          
  CAPSUserEnvironment += "audio/recording"
}

contains(MOBILE_EXTENSIONS, alarms) {  
  DEFINES += XQALARMS_NO_LIBRARY
  LIBS -= -lxqalarms

  HEADERS += $${SOURCES_PREFIX}/alarms/xqalarms.h \
             $${SOURCES_PREFIX}/alarms/xqalarms_p.h \
             $${SOURCES_PREFIX}/alarms/alarms_global.h

  SOURCES += $${SOURCES_PREFIX}/alarms/xqalarms.cpp \
             $${SOURCES_PREFIX}/alarms/xqalarms_p.cpp

  LIBS += -lalarmclient \
          -lalarmshared
          
  CAPSReadUserData += alarms
  CAPSWriteUserData += alarms
  CAPSReadDeviceData += alarms
  CAPSWriteDeviceData += alarms
}

contains(MOBILE_EXTENSIONS, installer) {

  DEFINES += XQINSTALLER_NO_LIBRARY
  LIBS -= -lxqinstaller

  HEADERS += $${SOURCES_PREFIX}/installer/xqinstaller.h \
             $${SOURCES_PREFIX}/installer/xqinstaller_p.h \
             $${SOURCES_PREFIX}/installer/installer_global.h

  SOURCES += $${SOURCES_PREFIX}/installer/xqinstaller.cpp \
             $${SOURCES_PREFIX}/installer/xqinstaller_p.cpp
             
  !exists($${EPOCROOT}epoc32/include/SWInstApi.h) {
    message("Warning: SW Installer Launcher API not found in your environment! (See: http://www.developer.nokia.com/Community/Wiki/SW_Installer_Launcher_API)")
  }

  LIBS += -lswinstcli \
          -lcommdb \
          -lapparc \
          -lefsrv \
          -lapgrfx
          
  CAPSTrustedUI += installer
}

contains(MOBILE_EXTENSIONS, accesspointmanager) {

  DEFINES += XQACCESSPOINTMANAGER_NO_LIBRARY
  LIBS -= -lxqaccesspointmanager
  
  HEADERS += $${SOURCES_PREFIX}/accesspointmanager/xqaccesspointmanager.h \
             $${SOURCES_PREFIX}/accesspointmanager/xqaccesspointmanager_s60_p.h \
             $${SOURCES_PREFIX}/accesspointmanager/accesspointmanager_global.h

  SOURCES += $${SOURCES_PREFIX}/accesspointmanager/xqaccesspointmanager.cpp \
             $${SOURCES_PREFIX}/accesspointmanager/xqaccesspointmanager_s60_p.cpp
             
  !exists($${EPOCROOT}epoc32/include/wlanmgmtcommon.h) {
    message("Warning: WLAN Management API not found in your environment! (See: http://www.developer.nokia.com/Community/Wiki/WLAN_Management_API)")
  }

  LIBS += -lcommdb \
          -lapengine \
          -lapsettingshandlerui \
          -lconnmon \
          -lcentralrepository \
          -lesock \
          -lecom \
          -lefsrv
          
  CAPSReadUserData += accesspointmanager
}

contains(MOBILE_EXTENSIONS, landmarks) {

  DEFINES += XQLANDMARKS_NO_LIBRARY
  LIBS -= -lxqlandmarks
  
  HEADERS += $${SOURCES_PREFIX}/landmarks/xqlandmarksmanager.h \
             $${SOURCES_PREFIX}/landmarks/xqlandmarksmanager_p.h \
             $${SOURCES_PREFIX}/landmarks/xqlandmark.h \
             $${SOURCES_PREFIX}/landmarks/xqlandmark_p.h \
             $${SOURCES_PREFIX}/landmarks/landmarks_global.h
        
  SOURCES += $${SOURCES_PREFIX}/landmarks/xqlandmarksmanager.cpp \
             $${SOURCES_PREFIX}/landmarks/xqlandmarksmanager_p.cpp \
             $${SOURCES_PREFIX}/landmarks/xqlandmark.cpp
             
  LIBS += -llbs \
          -leposlandmarks \
          -leposlmmultidbsearch \
          -leposlmsearchlib
          
  CAPSReadUserData += landmarks
  CAPSWriteUserData += landmarks
}

contains(MOBILE_EXTENSIONS, location) {

  DEFINES += XQLOCATION_NO_LIBRARY
  LIBS -= -lxqlocation
  
  HEADERS += $${SOURCES_PREFIX}/location/xqlocation.h \
             $${SOURCES_PREFIX}/location/xqlocation_stub_p.h \
             $${SOURCES_PREFIX}/location/location_global.h
             
  SOURCES += $${SOURCES_PREFIX}/location/xqlocation.cpp \
             $${SOURCES_PREFIX}/location/xqlocation_s60_p.cpp

  LIBS += -llbs
          
  CAPSLocation += location
}

contains(MOBILE_EXTENSIONS, media) {

  DEFINES += XQMEDIA_NO_LIBRARY
  LIBS -= -lxqmedia
  
  HEADERS += $${SOURCES_PREFIX}/media/xqmedia.h \
             $${SOURCES_PREFIX}/media/xqmedia_p.h \
             $${SOURCES_PREFIX}/media/media_global.h
  
  SOURCES += $${SOURCES_PREFIX}/media/xqmedia.cpp \
             $${SOURCES_PREFIX}/media/xqmedia_p.cpp
  
  LIBS += -lcontentlistingframework \
          -lapmime \
          -lcommonui \
          -lexiflib.dll \
          -lefsrv 
}

contains(MOBILE_EXTENSIONS, messaging) {

  DEFINES += XQMESSAGING_NO_LIBRARY
  LIBS -= -lxqmessaging
  
  HEADERS += $${SOURCES_PREFIX}/messaging/xqmessaging.h \
             $${SOURCES_PREFIX}/messaging/xqmessaging_s60_p.h \
             $${SOURCES_PREFIX}/messaging/messaging_global.h
             
  SOURCES += $${SOURCES_PREFIX}/messaging/xqmessaging.cpp \
             $${SOURCES_PREFIX}/messaging/xqmessaging_s60_p.cpp
             
  INCLUDEPATH += /epoc32/include/app \
                 /epoc32/include/platform/app
             
  LIBS += -lsendas2 \
          -lmsgs \
          -letext \
          -lefsrv \
          -lcharconv \
          -lgsmu \
          -limcm \
          -lbafl \
          -lmtur
  
  CAPSNetworkServices += messaging
  CAPSLocalServices += messaging
  CAPSReadUserData += messaging
  CAPSWriteUserData += messaging
  CAPSUserEnvironment += messaging
  CAPSReadDeviceData += messaging
  CAPSWriteDeviceData += messaging
}

contains(MOBILE_EXTENSIONS, profile) {

  DEFINES += XQPROFILE_NO_LIBRARY
  LIBS -= -lxqprofile

  HEADERS += $${SOURCES_PREFIX}/profile/xqprofile.h \
             $${SOURCES_PREFIX}/profile/xqprofile_p.h \
             $${SOURCES_PREFIX}/profile/cflightmodechecker.h \
             $${SOURCES_PREFIX}/profile/profile_global.h

  SOURCES += $${SOURCES_PREFIX}/profile/xqprofile.cpp \
             $${SOURCES_PREFIX}/profile/xqprofile_p.cpp \
             $${SOURCES_PREFIX}/profile/cflightmodechecker.cpp
             
  INCLUDEPATH += /epoc32/include/app \
                 /epoc32/include/platform/app
             
  LIBS += -lprofileengine \
          -letel3rdparty \
          -lfeatdiscovery
             
  CAPSWriteDeviceData += profile
}

contains(MOBILE_EXTENSIONS, resourceaccess) {

  DEFINES += XQRESOURCEACCESS_NO_LIBRARY
  LIBS -= -lxqresourceaccess

  HEADERS += $${SOURCES_PREFIX}/resourceaccess/xqresourceaccess.h \
             $${SOURCES_PREFIX}/resourceaccess/xqresourceaccess_p.h \
             $${SOURCES_PREFIX}/resourceaccess/resourceaccess_global.h

  SOURCES += $${SOURCES_PREFIX}/resourceaccess/xqresourceaccess.cpp \
             $${SOURCES_PREFIX}/resourceaccess/xqresourceaccess_p.cpp
             
  LIBS += -lbafl \
          -lefsrv
}

contains(MOBILE_EXTENSIONS, settingsmanager) {

  DEFINES += XQSETTINGSMANAGER_NO_LIBRARY
  LIBS -= -lxqsettingsmanager
  
  HEADERS += $${SOURCES_PREFIX}/settingsmanager/xqsettingskey.h \
             $${SOURCES_PREFIX}/settingsmanager/xqsettingsmanager.h \
             $${SOURCES_PREFIX}/settingsmanager/xqsettingsmanager_p.h \
             $${SOURCES_PREFIX}/settingsmanager/settingshandlerbase.h \
             $${SOURCES_PREFIX}/settingsmanager/ccentralrepositoryhandler.h \
             $${SOURCES_PREFIX}/settingsmanager/cpublishandsubscribehandler.h \
             $${SOURCES_PREFIX}/settingsmanager/cenrepmonitor.h \
             $${SOURCES_PREFIX}/settingsmanager/pubsubmonitor.h \
             $${SOURCES_PREFIX}/settingsmanager/xqcentralrepositoryutils.h \
             $${SOURCES_PREFIX}/settingsmanager/xqcentralrepositoryutils_p.h \
             $${SOURCES_PREFIX}/settingsmanager/xqpublishandsubscribeutils.h \
             $${SOURCES_PREFIX}/settingsmanager/xqpublishandsubscribeutils_p.h \
             $${SOURCES_PREFIX}/settingsmanager/xqcentralrepositorysearchcriteria.h \
             $${SOURCES_PREFIX}/settingsmanager/xqpublishandsubscribesecuritypolicy.h \
             $${SOURCES_PREFIX}/settingsmanager/settingsmanager_global.h

  SOURCES += $${SOURCES_PREFIX}/settingsmanager/xqsettingskey.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqsettingsmanager.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqsettingsmanager_p.cpp \
             $${SOURCES_PREFIX}/settingsmanager/settingshandlerbase.cpp \
             $${SOURCES_PREFIX}/settingsmanager/ccentralrepositoryhandler.cpp \
             $${SOURCES_PREFIX}/settingsmanager/cpublishandsubscribehandler.cpp \
             $${SOURCES_PREFIX}/settingsmanager/cenrepmonitor.cpp \
             $${SOURCES_PREFIX}/settingsmanager/pubsubmonitor.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqcentralrepositoryutils.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqcentralrepositoryutils_p.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqpublishandsubscribeutils.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqpublishandsubscribeutils_p.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqcentralrepositorysearchcriteria.cpp \
             $${SOURCES_PREFIX}/settingsmanager/xqpublishandsubscribesecuritypolicy.cpp
  
  LIBS += -lcentralrepository \
          -lcommonengine
}

contains(MOBILE_EXTENSIONS, sysinfo) {

  DEFINES += XQSYSINFO_NO_LIBRARY
  LIBS -= -lxqsysinfo
  
  HEADERS += $${SOURCES_PREFIX}/sysinfo/xqsysinfo.h \
             $${SOURCES_PREFIX}/sysinfo/xqsysinfo_p.h \
             $${SOURCES_PREFIX}/sysinfo/cdeviceinfo.h \
             $${SOURCES_PREFIX}/sysinfo/networksignalmonitor.h \
             $${SOURCES_PREFIX}/sysinfo/batterymonitor.h \
             $${SOURCES_PREFIX}/sysinfo/sysinfo_global.h

  SOURCES += $${SOURCES_PREFIX}/sysinfo/xqsysinfo.cpp \
             $${SOURCES_PREFIX}/sysinfo/xqsysinfo_p.cpp \
             $${SOURCES_PREFIX}/sysinfo/cdeviceinfo.cpp \
             $${SOURCES_PREFIX}/sysinfo/networksignalmonitor.cpp \
             $${SOURCES_PREFIX}/sysinfo/batterymonitor.cpp
  
  LIBS += -letel3rdparty \
          -lsysutil \
          -lefsrv \
          -lfeatdiscovery
  
  CAPSReadDeviceData += sysinfo
}

contains(MOBILE_EXTENSIONS, utils) {

  DEFINES += XQUTILS_NO_LIBRARY
  LIBS -= -lxqutils
  
  HEADERS += $${SOURCES_PREFIX}/utils/xqutils.h \
             $${SOURCES_PREFIX}/utils/xqutils_p.h \
             $${SOURCES_PREFIX}/utils/xqconversions.h \
             $${SOURCES_PREFIX}/utils/utils_global.h

  SOURCES += $${SOURCES_PREFIX}/utils/xqutils.cpp \
             $${SOURCES_PREFIX}/utils/xqutils_p.cpp \
             $${SOURCES_PREFIX}/utils/xqconversions.cpp
             
  LIBS += -lapmime \
          -lcommonui \
          -lplatformenv \
          -lcharconv
}

# Check and warn if any (known) required capability is missing
!contains( TARGET.CAPABILITY, [Aa]ll ) {
  capWarn = "Missing capability: Mobile Extensions/%1 needs %2"    
  for(ext, CAPSNetworkServices): !contains(TARGET.CAPABILITY, NetworkServices): warning($$sprintf($$capWarn,$$ext,NetworkServices))
  for(ext, CAPSUserEnvironment): !contains(TARGET.CAPABILITY, UserEnvironment): warning($$sprintf($$capWarn,$$ext,UserEnvironment))
  for(ext, CAPSWriteDeviceData): !contains(TARGET.CAPABILITY, WriteDeviceData): warning($$sprintf($$capWarn,$$ext,WriteDeviceData))
  for(ext, CAPSReadDeviceData): !contains(TARGET.CAPABILITY, ReadDeviceData): warning($$sprintf($$capWarn,$$ext,ReadDeviceData))    
  for(ext, CAPSWriteUserData): !contains(TARGET.CAPABILITY, WriteUserData): warning($$sprintf($$capWarn,$$ext,WriteUserData))
  for(ext, CAPSLocalServices): !contains(TARGET.CAPABILITY, LocalServices): warning($$sprintf($$capWarn,$$ext,LocalServices))
  for(ext, CAPSReadUserData): !contains(TARGET.CAPABILITY, ReadUserData): warning($$sprintf($$capWarn,$$ext,ReadUserData))
  for(ext, CAPSTrustedUI): !contains(TARGET.CAPABILITY, TrustedUI): warning($$sprintf($$capWarn,$$ext,TrustedUI))
  for(ext, CAPSLocation): !contains(TARGET.CAPABILITY, Location): warning($$sprintf($$capWarn,$$ext,Location))    
}

# eof
